package com.example.demo.service.impl;

import com.example.demo.Util.Result;
import com.example.demo.Util.ResultUtil;
import com.example.demo.mapper.MajorMap;
import com.example.demo.po.Major;
import com.example.demo.service.MajorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.thymeleaf.util.StringUtils;

@Service
public class MajorServiceImpl implements MajorService {
    @Autowired
    MajorMap majorMap;

    @Override
    public Result SaveMajor(Major major) {
        if(major == null){
            return ResultUtil.fail("参数空");
        }
        if(StringUtils.isEmpty(major.getName())){
            return ResultUtil.fail("名字必填");
        }

        majorMap.SaveMajor(major);
        return ResultUtil.success(major);
    }

    @Override
    public Result UpdateMajor(Major major) {
        if(major == null){
            return ResultUtil.fail("参数空");
        }
        if(StringUtils.isEmpty(major.getName())){
            return ResultUtil.fail("名字必填");
        }
        return ResultUtil.success("更新成功");
    }

    @Override
    public Result DeleteMajor(Major major) {

        return null;
    }
}
